
import sqlite3
#1 打开或创建数据库文件
conn = sqlite3.connect("test.db")
print("打开数据库成功")
# 2 获取游标
cur = conn.cursor();
sql = '''
    create table tests(
        id int primary key not null,
        name text not null,
        age int not null,
        address char(50),
        salary real);
'''
# 插入
sql1 = '''
    insert into tests(id,name,age,address,salary)
    values(11,'龙',30,"sdf",2000);
'''
# 查询
sql2 = '''
    select id,name,age,address,salary from tests
'''
# 3 执行
#ur.execute(sql2)
res = cur.execute(sql2)
for row in res:
    print(row[0],row[1],row[2],row[3],row[4])
#conn.commit()
conn.close()



